package com.xingda.packing.dmss.service;

import com.xingda.packing.dmss.config.appset.IAppSet;
import com.xingda.packing.dmss.domain.PackProductionLine;
import com.xingda.packing.dmss.domain.ShuntProductionLine;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component("packLineDMSSService")
@Slf4j
public class PackLineService {
    @Resource
    List<IAppSet> appSets;
    @Resource
    PackProductionLine packProductionLine;

    @Resource
    ShuntProductionLine shuntProductionLine;

    public void start() {
        appSets.forEach(IAppSet::init);
        boolean env = packProductionLine.getEnv().startsWith("xd-prod");
        log.info("----------------加载左侧装箱各区域初始状态----------------");
        packProductionLine.initStatus(1);
        log.info("----------------加载右侧装箱各区域初始状态----------------");
        packProductionLine.initStatus(2);
        log.info("----------------加载分流区域初始状态----------------");
        shuntProductionLine.initStatus();
        log.info("----------------加载初始报警初始状态-------------------");
        packProductionLine.initAlarmType();
        if (env) {
            log.info("----------------左侧装箱启动----------------");
            packProductionLine.start(1);
            log.info("----------------右侧装箱启动----------------");
            packProductionLine.start(2);
            log.info("----------------分流模块启动----------------");
            shuntProductionLine.start();
        }
    }
}
